<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>系统管理-通用配置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" /></head>

<body class="childrenBody">
<form class="layui-form">
	<input type="hidden" id="id" name="id" value="${sysConfig.id}" />

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;配置码</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="code" value="${sysConfig.code}" placeholder="请输入配置码" lay-verify="required" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">类型</label>
		<div class="layui-input-block">
			<input type="radio" name="type" lay-filter="type"  value="1" title="文本框" <#if !(sysConfig.type?if_exists&&sysConfig.type=='2')>checked</#if>>
			<input type="radio" name="type" lay-filter="type"  value="2" title="富文本" <#if sysConfig.type?if_exists&&sysConfig.type=='2'>checked</#if>>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12" id="typeNameSelect">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;配置内容</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="name" value="${sysConfig.content}" placeholder="请输入配置内容" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12" style="display: none" id="typeContentSelect">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;配置内容</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="content"  id="content" lay-verify="content" placeholder="请输入配置内容">${sysConfig.content}</textarea></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
			<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button></div>
	</div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['form', 'jquery', 'baseUtil', 'pageUtil','richTxtUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
			richTxtUtil = layui.richTxtUtil,
            baseUtil = layui.baseUtil,
            pageUtil = layui.pageUtil;

		//KnifeZ富文本
		var index=richTxtUtil.layeditKnifezBuild("content",300);

		form.on('radio(type)', function (data) {
			if(data.value=="2"){
				$("#typeContentSelect").show();
				$("#typeNameSelect").hide();
			}else{
				$("#typeContentSelect").hide();
				$("#typeNameSelect").show();
			}
		});

        form.on('submit(submitBtn)',
            function(data) {
        		var type = data.field.type;
        		if (type == "2") {
					data.field.content=richTxtUtil.layeditBuildContent(index);
				}  else {
        			data.field.content = data.field.name;
				}
                baseUtil.postMethodResult("/sysConfig/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });</script>
</body>

</html>